import type { AxiosInstance } from 'axios';
import apiAxiosInstance from './apiInstance';
import type { ThemesType } from '../types/themes';

class ThemesService {
  constructor(private client: AxiosInstance) {}

  async getAllTheme(): Promise<ThemesType[]> {
    const response = await this.client<ThemesType[]>('/api/themes');
    if (response.status !== 200)
      return Promise.reject(
        new Error(`Wrong status code (expected 200, received: ${response.status})`),
      );
    return response.data;
  }
}

export default new ThemesService(apiAxiosInstance);
